//
//  UIButton + Extension.swift
//  WeiBo
//
//  Created by wukeng-mac on 16/8/22.
//  Copyright © 2016年 wukeng. All rights reserved.
//

import UIKit

extension UIButton{
    class func setImage(imageName : String, bgImageName : String) -> UIButton {
        let btn = UIButton()
        btn.setImage(UIImage(named: imageName), forState: .Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        btn.setBackgroundImage(UIImage(named: bgImageName), forState: .Normal)
        btn.setBackgroundImage(UIImage(named: bgImageName + "_highlighted"), forState: .Highlighted)
        btn.sizeToFit()
        return btn;
    }
    
    convenience init(imageName : String, bgImageName : String){
        self.init()
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        setBackgroundImage(UIImage(named: bgImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: bgImageName + "_highlighted"), forState: .Highlighted)
        sizeToFit()
    }
}
